package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.FaDoorshow1;
import com.ruoyi.system.service.IFaDoorshow1Service;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 考勤统计Controller
 * 
 * @author xiaohe
 * @date 2024-11-14
 */
@Controller
@RequestMapping("/system/doorshow1")
public class FaDoorshow1Controller extends BaseController
{
    private String prefix = "system/doorshow1";

    @Autowired
    private IFaDoorshow1Service faDoorshow1Service;

    @RequiresPermissions("system:doorshow1:view")
    @GetMapping()
    public String doorshow1()
    {
        return prefix + "/doorshow1";
    }

    /**
     * 查询考勤统计列表
     */
    @RequiresPermissions("system:doorshow1:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(FaDoorshow1 faDoorshow1)
    {
        startPage();
        List<FaDoorshow1> list = faDoorshow1Service.selectFaDoorshow1List(faDoorshow1);
        return getDataTable(list);
    }

    /**
     * 导出考勤统计列表
     */
    @RequiresPermissions("system:doorshow1:export")
    @Log(title = "考勤统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(FaDoorshow1 faDoorshow1)
    {
        List<FaDoorshow1> list = faDoorshow1Service.selectFaDoorshow1List(faDoorshow1);
        ExcelUtil<FaDoorshow1> util = new ExcelUtil<FaDoorshow1>(FaDoorshow1.class);
        return util.exportExcel(list, "考勤统计数据");
    }

    /**
     * 新增考勤统计
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存考勤统计
     */
    @RequiresPermissions("system:doorshow1:add")
    @Log(title = "考勤统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(FaDoorshow1 faDoorshow1)
    {
        return toAjax(faDoorshow1Service.insertFaDoorshow1(faDoorshow1));
    }

    /**
     * 修改考勤统计
     */
    @RequiresPermissions("system:doorshow1:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        FaDoorshow1 faDoorshow1 = faDoorshow1Service.selectFaDoorshow1ById(id);
        mmap.put("faDoorshow1", faDoorshow1);
        return prefix + "/edit";
    }

    /**
     * 修改保存考勤统计
     */
    @RequiresPermissions("system:doorshow1:edit")
    @Log(title = "考勤统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(FaDoorshow1 faDoorshow1)
    {
        return toAjax(faDoorshow1Service.updateFaDoorshow1(faDoorshow1));
    }

    /**
     * 删除考勤统计
     */
    @RequiresPermissions("system:doorshow1:remove")
    @Log(title = "考勤统计", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(faDoorshow1Service.deleteFaDoorshow1ByIds(ids));
    }
}
